package edu.gduf.controller;

import edu.gduf.dto.SigninSystemResult;
import edu.gduf.service.TeacherService;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;


/**
 * Created by zhang on 2017/4/13.
 */
@RestController
@RequestMapping("/teacher")
public class TeacherController {
    @Autowired
    private TeacherService teacherService;

    /**
     * 更新教师邮箱
     * @param tId
     * @param tEmail
     * @return
     */
    @ApiOperation(value = "教师修改邮箱",notes = "")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "tId", value = "教师工号", required = true, dataType = "Integer"),
            @ApiImplicitParam(name = "email", value = "教师邮箱", required = true, dataType = "String")
    })
    @RequestMapping(value = "/update/email", method = RequestMethod.POST)
    public SigninSystemResult updateEmail(int tId, String tEmail) {
        return teacherService.updateEmail(tId, tEmail);
    }

    /**
     * 更新教师密码
     * @param tId
     * @param sPassword 原密码
     * @param dPassword 新密码
     * @return
     */
    @ApiOperation(value = "教师登录",notes = "")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "tId", value = "教师工号", required = true, dataType = "Integer"),
            @ApiImplicitParam(name = "sPassword", value = "原教师密码", required = true, dataType = "String"),
            @ApiImplicitParam(name = "dPassword", value = "新教师密码", required = true, dataType = "String")
    })
    @RequestMapping(value = "/update/password", method = RequestMethod.POST)
    public SigninSystemResult updatePassword(int tId, String sPassword, String dPassword) {
        return  teacherService.updatePassword(tId, sPassword, dPassword);
    }

}
